package cn.iocoder.yudao.module.infra.convert.file;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileRespVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

import java.time.LocalDateTime;

@Mapper(uses = DateUtils.class, imports = {LocalDateTimeUtils.class})
public interface FileConvert {

    FileConvert INSTANCE = Mappers.getMapper(FileConvert.class);
    @Mappings(value = {
            @Mapping(source = "createTime", target = "createTime", qualifiedByName = "convertCreateTimeToCreateTime"),
    })
    FileRespVO convert(FileDO bean);

    @Named("convertCreateTimeToCreateTime")
    default LocalDateTime convertSuspendedToSuspensionState(String createTime) {
        return LocalDateTimeUtils.buildTime(createTime);
    }
    PageResult<FileRespVO> convertPage(PageResult<FileDO> page);

}
